/*
 * @Description:
 * @Version: 1.0
 * @Autor: wangmeng
 * @Date: 2024-01-18 13:49:57
 * @LastEditors: wamgmeng
 * @LastEditTime: 2024-01-19 20:22:54
 */
import { createApp, reactive } from 'vue';
import './assets/style/index.scss';
import {
	ElButton,
	ElInput,
	ElSelect,
	ElInputNumber,
	ElTabs,
	ElTable,
	ElTableColumn,
	ElDialog,
	ElDatePicker,
	ElConfigProvider,
	ElPagination,
	ElForm,
	ElFormItem,
	ElIcon,
	ElMessage,
	ElMessageBox,
	ElMenu,
	ElMenuItem,
	ElDrawer,
	ElTag,
	ElTooltip,
	ElCascader,
	ElRadioGroup,
	ElRadio,
	ElCollapse,
	ElCollapseItem,
	ElPopover,
	ElRate
} from 'element-plus';
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import Cookies from 'js-cookie';
import App from './App.vue';
import router from './router';
import { checkIf404WithPost, getQuery, delTokenInUrl } from './assets/js/system';
import '@/assets/css/reset.css';
import '@/assets/css/common.scss';
import '@/assets/font/font.css';
import '@/assets/iconfont/iconfont.css';
import '@/assets/js/rem';

// token失效后取地址栏最新的token存入Cookies
const token = getQuery('token');
if (token) {
	Cookies.set('token', token);
	delTokenInUrl();
}

// 先校验录播接口是否存在
checkIf404WithPost('/api/rms/lesson/getResourceByLessonCode').then((is404) => {
	// 获取区域数据
	const globalData = reactive({
		title: '数智中台',
		is404
	});

	const app = createApp(App);
	app.config.globalProperties.$globalData = globalData;

	for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
		app.component(key, component);
	}

	app
		.use(ElButton)
		.use(ElInput)
		.use(ElSelect)
		.use(ElInputNumber)
		.use(ElTabs)
		.use(ElTable)
		.use(ElTableColumn)
		.use(ElDialog)
		.use(ElDatePicker)
		.use(ElForm)
		.use(ElFormItem)
		.use(ElConfigProvider, { locale: zhCn })
		.use(ElPagination)
		.use(ElIcon)
		.use(ElMessage)
		.use(ElMessageBox)
		.use(ElMenu)
		.use(ElMenuItem)
		.use(ElDrawer)
		.use(ElTag)
		.use(ElTooltip)
		.use(ElCascader)
		.use(ElRadioGroup)
		.use(ElRadio)
		.use(ElCollapse)
		.use(ElCollapseItem)
		.use(ElPopover)
		.use(ElRate)
		.use(router)
		.mount('#app');
});
